//
//  CellforSpecial.m
//  MY Project For Sport
//
//  Created by dllo on 16/2/26.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellforSpecial.h"
#import "ModelForHot.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <DKNightVersion.h>
#import "UIColor+Wonderful.h"
#define WEIGHT self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667

@interface CellforSpecial ()

@property (nonatomic, retain) UIImageView *team;
@property (nonatomic, retain) UILabel *leagueType;
@property (nonatomic, retain) UILabel *round;
@property (nonatomic, retain) UIView *myView;
@property (nonatomic, retain) UILabel *current;
@property (nonatomic, retain) UILabel *data;
@property (nonatomic, retain) UILabel *intro;


@end


@implementation CellforSpecial

-(void)dealloc {
    
    [_leagueType release];
    [_round release];
    [_data release];
    [_myView release];
    [_current release];
    [_team release];
    [_intro release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor linenColor], [UIColor grayColor]);
        
        [self createSubview];
        
    }
    
    return self;
    
}

#pragma mark - 创建 cell 上面的子视图
- (void)createSubview {
    
    
    self.myView = [[UIView alloc] init];
    [self.contentView addSubview:self.myView];
    self.myView.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor dimGray]);
    [_myView release];
    
    self.leagueType = [[UILabel alloc] init];
    self.leagueType.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.leagueType];
    [_leagueType release];
    
    self.round = [[UILabel alloc] init];
    self.round.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.round];
    [_round release];
    
    self.team = [[UIImageView alloc] init];
    [self.contentView addSubview:self.team];
    [_team release];
    
    self.current = [[UILabel alloc] init];
    [self.contentView addSubview:self.current];
    [_current release];
    
    self.data = [[UILabel alloc] init];
    [self.contentView addSubview:self.data];
    [_data release];
    
    self.intro = [[UILabel alloc] init];
    [self.contentView addSubview:self.intro];
    [_intro release];
}

-(void)layoutSubviews {
    
    [super layoutSubviews];
    //NSLog(@"%f %f", self.contentView.frame.size.width, HEIGHT);
    self.myView.frame = CGRectMake(3 * WEIGHTT, 5 * HEIGHTT, WEIGHT - 6 * WEIGHTT, HEIGHT - 10 * HEIGHTT);
    
    //  NSLog(@"%f", self.contentView.frame.size.height);
    self.leagueType.frame = CGRectMake(10 * WEIGHTT, 10 * HEIGHTT, WEIGHT / 9.4, HEIGHT / 8.4);
    self.leagueType.dk_textColorPicker = DKColorWithColors([UIColor grayColor], [UIColor whiteColor]);
    self.data.frame = CGRectMake(WEIGHT / 3 * 2, 10 * HEIGHTT, WEIGHT / 4, HEIGHT / 8.4);
    
    self.round.frame = CGRectMake(WEIGHT / 9.4 + (10 + 5) * WEIGHTT, 10 * HEIGHTT, WEIGHT / 9.4, HEIGHT / 8.4);
    //  self.round.textColor = [UIColor grayColor];
    
    self.round.dk_textColorPicker = DKColorWithColors([UIColor grayColor], [UIColor whiteColor]);
    
    self.team.frame = CGRectMake(10 * WEIGHTT, (10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + WEIGHT / 8.3 + 10 * HEIGHTT) / 2, WEIGHT / 8.3, WEIGHT / 8.3);

    self.intro.frame = CGRectMake(10 * WEIGHTT +  WEIGHT / 8.3 + 10 * WEIGHTT, 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT, WEIGHT / 2, WEIGHT / 8.3 * 2);
    self.intro.numberOfLines = 0;
    
    self.current.frame = CGRectMake(WEIGHT / 1.5 + WEIGHT / 10 + 20 * WEIGHTT,(10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + WEIGHT / 8.3 + 10 * HEIGHTT) / 2, WEIGHT / 8, WEIGHT / 8);
    
    self.current.backgroundColor = Wonderful_GrayColor2;
    self.current.layer.cornerRadius = WEIGHT / 16;
    self.current.layer.masksToBounds = YES;
       self.current.textAlignment = NSTextAlignmentCenter;
    
}

-(void)passModelForHot:(ModelForHot *)hotModel {
    
    self.leagueType.text = hotModel.LeagueType_cn;
    self.round.text = hotModel.Round_cn;
    self.data.text = hotModel.date;
    self.data.font = [UIFont systemFontOfSize:15];
    self.intro.text = hotModel.Title;
    [self.team sd_setImageWithURL:[NSURL URLWithString:hotModel.Flag1]];
    
    
    if ([hotModel.status isEqualToString:@"2"]) {
        
        self.current.text = @"进行中";
        self.current.textColor = [UIColor redColor];
        self.current.font = [UIFont systemFontOfSize:15];
 
        
    } else if ([hotModel.status isEqualToString:@"1"]) {
        
        self.current.text = @"未";
        self.current.textColor = [UIColor redColor];
        
        
    }
    
    else {
        
        self.current.text = @"结束";
        self.current.textColor = [UIColor blackColor];
    }
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
